package com.henu.engineer.controller;

import com.henu.engineer.dao.entity.student.Student;
import com.henu.engineer.dao.mapper.student.StudentXmlMapper;
import com.henu.engineer.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author noexcept
 * @date 2021/7/22 19:10
 */
@RestController
public class StudentController {

    @Autowired
    private StudentXmlMapper studentXmlMapper;

    @Autowired
    StudentService studentService;

    /**
     * 查询学生信息
     * @param id
     * @return
     */
    @GetMapping("/student/{id}")
    Student selectStudent(@PathVariable("id") String id, HttpSession session){
//        session.getAttribute()
        Student student = studentService.selectStudent(id);
        return student;
    }

    /**
     * 添加新学生
     * @param student
     * @return
     */
    @PostMapping("/student")
    boolean insertStudent(Student student,String pwd){
        return studentService.insertStudent(student,pwd);
    }

}
